import unittest
import requests
from crm_token import token #导入提前封装好的token
import warnings #导入关于警告的方法

class MyTestCase(unittest.TestCase):
    def test_userimg_upload(self):
        '''测试头像上传接口'''
        warnings.simplefilter('ignore',ResourceWarning)
        #上边这条代码可以忽略警告，方法是先导入warning方法，再使用上边这条代码
        head={'Admin-Token':token()}
        date={'userId':222}
        img={'file':('crm_upload_img01.jpg',open('D:/pycharm_git/test/crm_upload_img01.jpg',"rb"),'image/jpg')}
        up=requests.post('http://182.92.197.48:8080/system/user/updateImg',data=date,files=img,headers=head,timeout=3)
        # print(up.json())
        back=up.json()
        # 下面开始进行断言
        self.assertEqual(back['code'],0)
        # self.assertEqual(True, False)  # add assertion here

if __name__ == '__main__':
    unittest.main()
